home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 13 / 013.d81 / dos #38 < prev    next >
Text File  |  2022-08-26  |  3KB  |  146 lines

  1. ======================================
  2.        DOS & Don'ts -- Part 38
  3.  
  4.        by James Gregory Weiler
  5. ======================================
  6.  
  7.      Section 2: Relative files
  8.  
  9.  
  10.  Surprise!  The structure of RELative
  11.  
  12. files is almost exactly the same as
  13.  
  14. any other file type.  Yes, you can
  15.  
  16. start at the BAM, link through the
  17.  
  18. directory, and then link from one data
  19.  
  20. block to the next until you find the
  21.  
  22. end of the file.  The links work the
  23.  
  24. same old way, and the data is stored
  25.  
  26. the same old places, just as described
  27.  
  28. in map 6 in Part 37.
  29.  
  30.   What makes relative files special is
  31.  
  32. the way you can directly access any
  33.  
  34. piece of data out in the middle of the
  35.  
  36. file without bothering to read any of
  37.  
  38. the intervening data.  In other words,
  39.  
  40. you don't have to follow the file
  41.  
  42. links to find a given block of a
  43.  
  44. relative file.
  45.  
  46.   Well, all good things have a price,
  47.  
  48. and the price of relative files is
  49.  
  50. a beastie called the "side sector".
  51.  
  52. In essence, side sectors keep track
  53.  
  54. of exactly where on the disk any
  55.  
  56. given block of a relative file can
  57.  
  58. be found.  DOS uses side sectors as a
  59.  
  60. "short-cut" to the record you want in
  61.  
  62. a relative file.
  63.  
  64.   You remember from our discussion of
  65.  
  66. the directory that a file name entry
  67.  
  68. for a relative file has a link to
  69.  
  70. the first file block and a link to the
  71.  
  72. first side sector block.  In essence,
  73.  
  74. each relative file is two linked
  75.  
  76. files -- a data file made up of
  77.  
  78. ordinary data blocks, and an index
  79.  
  80. file built out of side sectors.
  81.  
  82.   Here's a chart of relative file
  83.  
  84. organization.  I hope you can
  85.  
  86. understand it.
  87.  
  88.  {CBM-A}------------------------------{CBM-S}
  89.  !Relative file directory entry.!
  90.  {CBM-Z}------{CBM-R}----------{CBM-R}------------{CBM-X}
  91.         V          V
  92.      {CBM-A}--{CBM-E}---{CBM-S}    {CBM-A}-{CBM-E}----{CBM-S}
  93. u    !side  {CBM-Q}--> !data  !
  94. n{CBM-A}-->!sector{CBM-Q}--> !blocks!
  95. i!   !# 1   {CBM-Q}--> !1-120 !
  96. v!   {CBM-Z}--{CBM-R}---{CBM-X}    {CBM-Z}-{CBM-R}----{CBM-X}
  97. e!      V          V
  98. r!   {CBM-A}--{CBM-E}---{CBM-S}    {CBM-A}-{CBM-E}-----{CBM-S}
  99. s!   !side  {CBM-Q}--> !data   !
  100. a{CBM-Q}-->!sector{CBM-Q}--> !blocks !
  101. l!   !# 2   {CBM-Q}--> !121-240!
  102.  !   {CBM-Z}--{CBM-R}---{CBM-X}    {CBM-Z}-{CBM-R}-----{CBM-X}
  103. l!      V          V
  104. i!   {CBM-A}--{CBM-E}---{CBM-S}    {CBM-A}-{CBM-E}-----{CBM-S}
  105. n!   !side  {CBM-Q}--> !data   !
  106. k{CBM-Z}-->!sector{CBM-Q}--> !blocks !
  107.      !# 3   {CBM-Q}--> !241-360!
  108.      {CBM-Z}------{CBM-X}    {CBM-Z}-------{CBM-X}
  109.  
  110.  
  111.   Each square on the left is a single
  112.  
  113. block.  Each square on the right is
  114.  
  115. 120 blocks.  The arrows are links.
  116.  
  117. The universal link on the left links
  118.  
  119. each side sector to every other side
  120.  
  121. sector.
  122.  
  123.   Now, let's see how DOS follows the
  124.  
  125. links to read data block 259.
  126.  
  127.   a) Read BAM - link to directory.
  128.   b) Read directory - link to side
  129.      sector 1.
  130.   c) Read side sector 1 - link to
  131.      side sector 3.
  132.   d) Read side sector 3 - link to
  133.      data block 259.
  134.  
  135.   Hmmm.  DOS only had to read four
  136.  
  137. blocks.  If it was trying to find
  138.  
  139. block 259 of a SEQ file it would have
  140.  
  141. to read all 258 of the preceding data
  142.  
  143. blocks.
  144.  
  145. =======< continued in Part 39 >=======
  146.